package com.mofang.ticketing.common.core.enums.base;

import com.mofang.ticketing.common.core.enums.EnumVO;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: 证件类型枚举
 * @author: ChenDongDong
 * @createDate: 2022/5/18 18:03
 * @version: 1.0
 */
@Getter
public enum CardTypeEnum {
    ID_CARD(1, "身份证"),
    OFFICER_CARD(2, "军官证"),
    PASSPORT(3, "护照"),
    OTHER(4, "其他"),
    ;
    private final Integer id;
    private final String src;

    CardTypeEnum(Integer id, String src) {
        this.id = id;
        this.src = src;
    }

    public static String getSrcById(Integer id) {
        for (CardTypeEnum m : CardTypeEnum.values()) {
            if (m.getId().equals(id)) {
                return m.getSrc();
            }
        }
        return null;
    }

    public static List<EnumVO> getKeyValueList() {
        List<EnumVO> list = new ArrayList<>();
        for (CardTypeEnum h : CardTypeEnum.values()) {
            EnumVO enumVo = new EnumVO();
            enumVo.setKey(h.getId());
            enumVo.setValue(h.getSrc());
            list.add(enumVo);
        }
        return list;
    }
}
